# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Gavin Yancey <gyancey@hmc.edu>
# Contributor: Timofey Titovets <nefelim4ag@gmail.com>

pkgname=bees
pkgver=0.9.3
pkgrel=1
pkgdesc="Best-Effort Extent-Same, a btrfs deduplicator daemon"
arch=('loong64' 'x86_64')
url="https://github.com/Zygo/bees"
license=('GPL3')
depends=('util-linux-libs' 'bash')
makedepends=('btrfs-progs' 'systemd')
source=("${pkgname}-${pkgver}.tar.gz"::"https://github.com/Zygo/bees/archive/v${pkgver}.tar.gz"
        "bees-fix-build.patch::https://github.com/Zygo/bees/commit/d6732c58e29b6f969e8b53c16541d1572a31c485.patch")
sha256sums=('83a65f5a1ac21dc33bd6864cf8d217cbb90745fbd5d4c81d2a8416895501f99e'
            'd08111d97ee1b8c1d3b7abcdc25872de965e472f318383e9121917667748d3c7')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i $srcdir/bees-fix-build.patch
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make BEES_VERSION="${pkgver}"
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make install DESTDIR="${pkgdir}" BEES_VERSION="${pkgver}"

  mv "${pkgdir}/usr/sbin" "${pkgdir}/usr/bin"
}
